package com.cmxh.shipper.service.impl;

import com.cmxh.shipper.mapper.DriverUserMapper;
import com.cmxh.shipper.pojo.DriverUser;
import com.cmxh.shipper.service.DriverUserService;
import com.cmxh.shipper.util.Md5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DriverUserServiceimpl implements DriverUserService {
    @Autowired
    private DriverUserMapper driverUserMapper;
    //添加用户
    @Override
    public int insert(DriverUser record) {
        String encrypt = Md5Util.encrypt(record.getPassword());//对密码进行加密
        record.setPassword(encrypt);
        int insert = driverUserMapper.insert(record);
        DriverUser logins = driverUserMapper.logins(record);
      if (logins!=null){
          return 1;
      }
        return insert;
    }

    @Override
    public int insertPhone(DriverUser record) {
        return driverUserMapper.insert(record);
    }

    ///登录
    @Override
    public DriverUser logins(DriverUser driverUser) {
        DriverUser driverUser1 = driverUserMapper.logins(driverUser);
        return driverUser1;
    }

    @Override
    public DriverUser selectByPrimaryKey(String phone) {
        DriverUser driverUser = driverUserMapper.selectByPrimaryKey(phone);
        return driverUser;
    }

    @Override
    public int updatePassword(DriverUser driverUser) {
        return driverUserMapper.updatePassword(driverUser);
    }
}
